package entityJPA;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;


/**
 * The persistent class for the position database table.
 * 
 */
@Entity
@Table(name="position")

@NamedQueries({
	@NamedQuery(name="Position.findAll", query="SELECT p FROM Position p"),
	@NamedQuery(name = "Position.findActive", query = "SELECT p FROM Position p JOIN p.positionstatus ps WHERE ps.value LIKE 'active'"),
	@NamedQuery(name = "Position.findInactive", query = "SELECT p FROM Position p JOIN p.positionstatus ps WHERE ps.value LIKE 'inactive'")})

public class Position implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(unique=true, nullable=false)
	private int idPosition;

	@Column(nullable=false)
	private int idUser;

	@Column(nullable=false, length=45)
	private String name;

	@Column(nullable=false)
	private int nrPersons;

	//bi-directional many-to-one association to Positiondescription
	@ManyToOne
	@JoinColumn(name="idPositionDescription", nullable=false)
	private Positiondescription positiondescription;

	//bi-directional many-to-one association to Positionstatus
	@ManyToOne
	@JoinColumn(name="idPositionStatus", nullable=false)
	private Positionstatus positionstatus;

	public Position() {
	}

	public int getIdPosition() {
		return this.idPosition;
	}

	public void setIdPosition(int idPosition) {
		this.idPosition = idPosition;
	}

	public int getIdUser() {
		return this.idUser;
	}

	public void setIdUser(int idUser) {
		this.idUser = idUser;
	}

	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getNrPersons() {
		return this.nrPersons;
	}

	public void setNrPersons(int nrPersons) {
		this.nrPersons = nrPersons;
	}

	public Positiondescription getPositiondescription() {
		return this.positiondescription;
	}

	public void setPositiondescription(Positiondescription positiondescription) {
		this.positiondescription = positiondescription;
	}

	public Positionstatus getPositionstatus() {
		return this.positionstatus;
	}

	public void setPositionstatus(Positionstatus positionstatus) {
		this.positionstatus = positionstatus;
	}
	public String toString(){
		return this.idPosition+" "+this.name+" "+this.nrPersons;
	}

}